﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
  <xsl:output method="xml" indent="no" />

  <xsl:template match="/">
    <xsl:apply-templates select="//div [@id = 'questions']" />
  </xsl:template>

  <xsl:template match="div[@class = 'question-summary']">
    <xsl:variable name="anchor" select="./div[@class = 'summary']/h3/a" />
    <xsl:variable name="uid" select="./@id" />

    <div style="padding-bottom:5px;">
      <a>
        <xsl:attribute name="target">_blank</xsl:attribute>
        <xsl:attribute name="href">
          <xsl:value-of select="concat('http://stackoverflow.com', $anchor/@href)" />
        </xsl:attribute>
        <strong><xsl:copy-of select="$anchor/node()" /></strong>
      </a>
      <div>
        <xsl:attribute name="id">so-excerpt-<xsl:value-of select="$uid"/></xsl:attribute>
        <xsl:value-of select="./div[@class = 'summary']/div [@class='excerpt']/text()" />
      </div>
    </div>

  </xsl:template>
</xsl:stylesheet>

